package com.bltec.emergency.mapper;

import com.bltec.emergency.model.ResExternal;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ResExternalMapper {
    //medical,communication,transport,shelter
    //插入一条resExternal记录
    @Insert("insert into res_external_res (medical,communication,transport,shelter," +
            "create_by,create_time,enable) " +
            "values(#{medical},#{communication},#{transport},#{shelter},#{createBy},#{createTime},#{enable})")
    boolean insert(ResExternal resExternal);

/*    //通过name字段删除resExternal记录
    @Delete("delete from res_external_res where name=#{name}")
    boolean deleteByName(String name);*/

    //通过id设置一条记录为不可用
    @Update("update res_external_res set enable=0 where id=#{id}")
    boolean setDisableById(Long id);

    //通过id更新一条记录
    @Update("update res_external_res set medical=#{medical},communication=#{communication},transport=#{transport}," +
            "shelter=#{shelter},update_by=#{updateBy},update_time=#{updateTime} where id=#{id}")
    boolean updateResExternalById(ResExternal resExternal);

/*
    //查找符合name字段的记录
    @Select("select id,medical,communication,transport,shelter,create_by,create_time,update_by,update_time,enable" +
            "from res_external_res where resExternal_name =#{name} and enable=1")
    ResExternal getResExternalByName(String name);

    //查找符合name字段的记录的id
    @Select("select id from res_external_res where resExternal_name =#{name} and enable=1")
    Integer getIdByName(String name);
*/

    //查找符合id字段的记录
    @Select("select id,medical,communication,transport,shelter,create_by,create_time,update_by,update_time,enable" +
            " from res_external_res where id =#{id} and enable=1")
    ResExternal getResExternalById(Long id);

    //查找所有记录
    @Select("select id,medical,communication,transport,shelter,create_by,create_time,update_by,update_time,enable" +
            " from res_external_res where enable=1")
    List<ResExternal> selectAll();
}